﻿package view.tips
{
    import com.greensock.*;
    import com.sh.game.global.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import morn.core.managers.*;
    import uiresource.tips.*;

    public class SpecialTipsGame extends SpecialTipsUI
    {
        private var image:Image;
        private var _data:Object;
        private var tween:TimelineLite;

        public function SpecialTipsGame()
        {
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._data = param1;
            var _loc_2:* = ConfigDictionary.data.item;
            var _loc_3:* = _loc_2[param1.itemid];
            txt_name.text = _loc_3.name;
            if (this.image)
            {
                if (this.image.parent)
                {
                    this.removeChild(this.image);
                }
                this.image = null;
            }
            if (this.tween)
            {
                this.tween.kill();
                this.tween = null;
            }
            txt_attribute.text = "<font color=\'#cf26a5\'>基础属性</font><br>" + this.getAttribute(_loc_3);
            if (App.asset.hasClass("png.temptation." + this._data.itemid))
            {
                this.image = new Image("png.temptation." + this._data.itemid);
                this.image.x = 280 - this.image.width >> 1;
                this.addChild(this.image);
                this.image.y = txt_name.y + txt_name.height;
                box_attribute.y = txt_name.y + txt_name.height + this.image.height;
            }
            else
            {
                box_attribute.y = txt_name.y + txt_name.height;
                App.mloader3.loadAssets([{url:Config.getUrl("assets/images/temptation/" + param1.itemid + ".swf"), type:ResLoader.SWF, size:100, priority:1}], new Handler(this.onComplete));
            }
            img_bg.height = box_attribute.y + box_attribute.height + 10;
            return;
        }// end function

        private function onComplete() : void
        {
            this.image = new Image("png.temptation." + this._data.itemid);
            this.image.x = 280 - this.image.width >> 1;
            this.addChild(this.image);
            this.image.y = txt_name.y + txt_name.height;
            this.image.alpha = 0;
            this.tween = new TimelineLite();
            this.tween.insert(new TweenLite(box_attribute, 0.3, {y:txt_name.y + txt_name.height + this.image.height}));
            this.tween.insert(new TweenLite(img_bg, 0.3, {height:img_bg.height + this.image.height}));
            this.tween.append(new TweenLite(this.image, 0.3, {alpha:1}));
            return;
        }// end function

        public function getAttribute(param1:Object) : String
        {
            var _loc_2:String = "";
            if (param1.phyAttMax > 0)
            {
                _loc_2 = _loc_2 + ("物理攻击: " + param1.phyAtt + " - " + param1.phyAttMax + "<br>");
            }
            if (param1.magicAttMax > 0)
            {
                _loc_2 = _loc_2 + ("魔法攻击: " + param1.magicAtt + " - " + param1.magicAttMax + "<br>");
            }
            if (param1.taoAttMax > 0)
            {
                _loc_2 = _loc_2 + ("道术攻击: " + param1.taoAtt + " - " + param1.taoAttMax + "<br>");
            }
            if (param1.pureatk > 0)
            {
                _loc_2 = _loc_2 + ("混乱攻击: " + param1.pureatk + "<br>");
            }
            if (param1.phyDefMax > 0)
            {
                _loc_2 = _loc_2 + ("物理防御: " + param1.phyDef + " - " + param1.phyDefMax + "<br>");
            }
            if (param1.magicDefMax > 0)
            {
                _loc_2 = _loc_2 + ("魔法防御: " + param1.magicDef + " - " + param1.magicDefMax + "<br>");
            }
            if (param1.puredef > 0)
            {
                _loc_2 = _loc_2 + ("混乱防御: " + param1.puredef + "<br>");
            }
            if (param1.hp > 0)
            {
                _loc_2 = _loc_2 + ("血量上限: " + String(int(param1.hp) / 100) + "%<br>");
            }
            if (param1.mp > 0)
            {
                _loc_2 = _loc_2 + ("魔法上限: " + String(int(param1.mp) / 100) + "%<br>");
            }
            if (param1.luck > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>幸    运: +" + param1.luck + "</font><br>");
            }
            if (param1.critRate > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>暴击伤害: +" + String(int(param1.critRate) / 100) + "%</font><br>");
            }
            if (param1.critical > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>暴    击: +" + param1.critical + "</font><br>");
            }
            if (param1.attackSpeed > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>攻击速度:+" + param1.attackSpeed + "</font><br>");
            }
            if (param1.pkatt > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>PK伤害: +" + int(param1.pkatt / 100) + "%</font><br>");
            }
            if (param1.pkdef > 0)
            {
                _loc_2 = _loc_2 + ("<font color=\'#ff0000\'>PK免伤: +" + int(param1.pkdef / 100) + "%</font><br>");
            }
            return _loc_2;
        }// end function

    }
}
